package com.dx.chat.kafka.service;

import org.apache.kafka.common.PartitionInfo;

import java.util.List;
import java.util.function.Function;

/**
 * kafka 生产者接口
 */
public interface IKafkaProducerService<T> {
    /**
     * 普通发送消息，默认partition为0
     */
    void sendMessage(String topic, T message);

    void sendMessage(String topic, T message, Function function, Function error);

    void sendMessage(String topic, String key, T message, Function function, Function error);

    /**
     * 根据key进行hash取模路由到partition中
     */
    void sendMessage(String topic, String key, T message);

    void sendMessage(String topic, Integer partition, String key, T message);

    List<PartitionInfo> partitionsFor(String topic);
}
